package com.superman.supermarket.client.activity;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
import com.superman.mvpframe.client.ajax.PostManAsyncCallBack;
import com.superman.mvpframe.client.event.ReloadEvent;
import com.superman.mvpframe.client.mvp.IPageView;
import com.superman.mvpframe.client.mvp.IPageViewPresenter;
import com.superman.mvpframe.client.utils.XJsonUtil;
import com.superman.mvpframe.client.widget.mescroll.UpAndDownCallBack;
import com.superman.supermarket.client.mvp.ShopAbstractActivity;
import com.superman.supermarket.client.view.refundlist.RefundListView;

/**
 * 退款列表
 * 
 * @author superman
 * @version 2018年8月18日下午7:14:43
 */
public class RefundListActivity extends ShopAbstractActivity implements UpAndDownCallBack {

	@Inject
	RefundListView refundListView;

	@Override
	public void getListDataByPage(int page) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("PAGE_INDEX", page);
		postman.post("order/refund/list", map, new PostManAsyncCallBack() {

			@Override
			public void onBusinessError(String statusCode) {

			}

			@Override
			public void onBusinessOK(String response) {
				refundListView.getPullToRefreshView().endBySize(XJsonUtil.getList(response), XJsonUtil.getCount(response));
			}
		});
	}

	@Override
	public IPageView getView() {
		return refundListView;
	}

	@Override
	public IPageViewPresenter getViewPresenter() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onActivity(EventBus eventBus) {
		eventBus.addHandler(ReloadEvent.TYPE, new ReloadEvent.ReloadEventHandler() {

			@Override
			public void reload(ReloadEvent event) {
				refundListView.getPullToRefreshView().clearListAndResetScroll();
			}
		});
	}

	@Override
	public void popToRefresh() {
		// TODO Auto-generated method stub

	}

	@Override
	public void popToRefresh(Object contextData) {
		// TODO Auto-generated method stub

	}

	@Override
	public void pushToRefresh() {
		refundListView.getPullToRefreshView().initMeScroll(this, "1.2rem", "0");
	}

}
